package com.chuzhiyun.chengguoxy.utlis;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemChildClickListener;

import androidx.annotation.Nullable;

public abstract class NewOnItemChildClickListener implements OnItemChildClickListener {
    private long mLastClickTime;
    private long timeInterval = 1000L;

    public NewOnItemChildClickListener() {

    }

    public NewOnItemChildClickListener(long interval) {
        this.timeInterval = interval;
    }

    @Override
    public void onItemChildClick(@Nullable BaseQuickAdapter adapter, @Nullable View view, int position)
    {
        long nowTime = System.currentTimeMillis();
        if (nowTime - mLastClickTime > timeInterval) {
            // 单次点击事件
            onSingleClick(adapter,view,position);
            mLastClickTime = nowTime;
        }
    }

    protected abstract void onSingleClick(BaseQuickAdapter adapter, View view, int position);
}
